package com.olinsports.system.olinsportssystem.controller;

import com.olinsports.system.olinsportssystem.manager.CommodityConsumptionManager;
import com.olinsports.system.olinsportssystem.manager.SiteConsumptionDetailsManager;
import com.olinsports.system.olinsportssystem.model.CommodityConsumption;
import com.olinsports.system.olinsportssystem.model.SiteConsumptionDetails;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by Administrator on 2017/7/22.
 */
@Controller
@RequestMapping("commConsum")
public class CommodityConsumptionController {
    @Autowired
    private CommodityConsumptionManager commodityConsumptionManager;

    @RequestMapping("/selectBySaveKey")
    @ResponseBody
    public CommodityConsumption selectByKey(int conKey){
        return commodityConsumptionManager.selectByKey(conKey);
    }

    @RequestMapping("/listCommConsum")
    @ResponseBody
    public Map listCommConsum(String page, String rows,String sord, String sidx){
        return commodityConsumptionManager.listCommConsum(page,rows,sord,sidx);
    }

    @RequestMapping("/searchDate")
    @ResponseBody
    public Map searchDate(String page, String rows,String startDate,String endDate){
        return commodityConsumptionManager.searchDate(page,rows,startDate,endDate);
    }

    @RequestMapping("/toDcExcel")
    @ResponseBody
    public ModelAndView toDcExcel(String startDate, String endDate, HSSFWorkbook workbook) throws Exception{
        return commodityConsumptionManager.toDcExcel(startDate,endDate,workbook);
    }

    @RequestMapping("/searchSelf")
    @ResponseBody
    public Map searchSelf(String page, String rows,String field,String fieldValue){
        return commodityConsumptionManager.searchSelf(page,rows,field,fieldValue);
    }

    @RequestMapping("/insertAll")
    @ResponseBody
    public int insertAll(@RequestBody String commDetailed){
        System.out.println(commDetailed);
        return commodityConsumptionManager.insertAll(commDetailed);
    }

    @RequestMapping("/getSumTotal")
    @ResponseBody
    public int getSumTotal(){
        return commodityConsumptionManager.getSumTotal();
    }
}
